package com.viphuli.http.handler;

import java.util.List;

import android.view.View;

import com.viphuli.adapter.TicketAdapter;
import com.viphuli.fragment.AccountTicketFragment;
import com.viphuli.http.bean.page.AccountConsumeTicketPage;
import com.viphuli.http.bean.part.PurchasePayTicket;

public class AccountTicketResponseHandler extends MyBaseHttpResponseHandler<AccountTicketFragment, AccountConsumeTicketPage> {

	@Override
	public void deal() {
		List<PurchasePayTicket> list = page.getTicketList();
		
		if (list != null && !list.isEmpty()) {

			caller.getList().addAll(list);//填充数据
			
			if (caller.getListView().getAdapter() == null) {
				TicketAdapter adapter = new TicketAdapter(caller, caller.getList());
				caller.getListView().setAdapter(adapter);
				caller.setBaseAdapter(adapter);
			}else {//填充数据后通知视图更新
				caller.getBaseAdapter().notifyDataSetChanged();
			}

			caller.notEmpty();
			caller.getListView().setVisibility(View.VISIBLE);
			caller.getEmpty().setVisibility(View.GONE);

		} else {
//			caller.doShowEmpty();
			caller.notEmpty();
			caller.getListView().setVisibility(View.GONE);
			caller.getEmpty().setVisibility(View.VISIBLE);

		}
	}

}
